Separate q,k,v projection in sliding attention layers - #3376
Merged
Conversation
patrickji2014
requested review from
QiliangCui,
jrplatin,
kwang3939,
kyuyeunk,
lk-chen,
vipannalla,
yiw-wang and
yunyao-gg
as code owners
August 11, 2026 22:00
DescriptionStart with a short description of what the PR does and how this is a change from The rest of the description includes relevant details and context, examples:
If the change fixes a Github issue, please include a link, e.g.,: TestsPlease describe how you tested this change, and include any instructions and/or ChecklistBefore submitting this PR, please make sure:
|
patrickji2014
force-pushed
the
patrickji.qkv_weight_unmerge
branch
from
August 11, 2026 22:49
b95bf52 to
a35633c
Compare
Signed-off-by: patrickji <patrickji2014@gmail.com>
patrickji2014
force-pushed
the
patrickji.qkv_weight_unmerge
branch
from
August 11, 2026 23:03
a35633c to
c0693df
Compare
lk-chen
reviewed
Aug 12, 2026
lk-chen
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, could you update PR title and description?
Signed-off-by: patrickji <patrickji2014@gmail.com>
lk-chen
approved these changes
Aug 12, 2026
patrickji2014
enabled auto-merge (squash)
August 12, 2026 20:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In Gemma-4, existing model implementation use concatenate qkv weights in head_dim. when compute the qkv projections, this requires split the concatenated value back into q, k, v, which introduces some overhead from slice operations.
Perf metric
Batch size 818
With the change in this pr, 2.8% lift in the tok/s is observed.
baseline is run with xla_tpu_allow_conv_input_fusion_with_downcast_convert=true to
Fuse Sub-16 bytes Quantization Into Matmul
Batch Size 512
Baseline Total token throughput (tok/s): 137,241
With this pr, Total token throughput (tok/s): 139,284
Tests
One shot correctness check
Checklist
Before submitting this PR, please make sure: